//
//  CollectionViewController.m
//  Leisure
//
//  Created by Alex on 16/7/5.
//  Copyright © 2016年 蓝鸥科技有限公司西安分公司. All rights reserved.
//

#import "CollectionViewController.h"

@interface CollectionViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation CollectionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ReadListCell" bundle:nil] forCellReuseIdentifier:@"ReadListModel_cell"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return [[CoreDataManager shareCoreDataManager]selectAllCollectionModel].count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    ReadListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReadListModel_cell" forIndexPath:indexPath];
    
    [cell setCellWithCollecionModel:[[CoreDataManager shareCoreDataManager]selectAllCollectionModel][indexPath.row]];
    
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 200.f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    CollectonDetailViewController *VC = [[CollectonDetailViewController alloc]initWithNibName:@"CollectonDetailViewController" bundle:nil];
    VC.html = [[[CoreDataManager shareCoreDataManager]selectAllCollectionModel][indexPath.row] html];
    
    [self.navigationController pushViewController:VC animated:YES];
    
}


@end
